package demo.aop.controller;


import demo.aop.introduction.CommonParent;
import demo.aop.service.RoleService;
import demo.aop.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class DeclareParentsTestController {

    @Autowired
    UserService userService;

    @Autowired
    RoleService roleService;

    @GetMapping("/declare")
    public String test(){
        userService.save();
        return "ok";
    }


    @GetMapping("/declare2")
    public String test2(){
        log.info(roleService.getClass().toString());
        CommonParent commonParent=(CommonParent)roleService;
        commonParent.doSomething();
        roleService.save();
        return "ok";
    }
}
